package com.cherry.ssm.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class LogHelper {
	
//	private static  Logger logger = Logger.getLogger("LogHelper");
	private static Logger logger = LoggerFactory.getLogger(LogHelper.class);
	
	public static void logMethodCalled(String methodName){
		String message = String.format("【方法】 %s 调用", methodName);
		LogHelper.log(message);
	}
	
	public static void logParamValue(String paramName, Object paramValue){
		String message = String.format("【参数】-%s : %s", paramName, JSON.toJSONStringWithDateFormat(paramValue,"yyyy-MM-dd",SerializerFeature.WriteDateUseDateFormat));
		LogHelper.log(message);
	}


	public static void logMessage(String message) {
		LogHelper.log("【消息】" + message);
	}
	

	public static void logTime(Long time) {
		LogHelper.log("【时间】" + time);
	}
	
	public static void logError(String error){
		LogHelper.logger.error("【异常】" + error);
	}
	
	public static void logError(String error, Exception ex){
		LogHelper.logger.error("【异常】" + error, ex);
	}
	
	public static void log(String message) {
		LogHelper.logger.info(message);
	}
}
